const path = require('path')


const { getPromptModules } = require('./util/index')

const Creator = require('./Creator')

async function create (projectName, options) { // aaa, {}
  const cwd = options.cwd || process.cwd() // /Users/xqd/code-2022/cli-demo
  const inCurrent = projectName === '.' // false
  const name = inCurrent ? path.relative('../', cwd) : projectName // aaa
  const targetDir = path.resolve(cwd, projectName || '.') // /Users/xqd/code-2022/cli-demo/aaa

  // 项目存在与否校验
  
  const creator = new Creator(name, targetDir, getPromptModules())
  await creator.create(options)
}

module.exports = (...args) => { // aaa {}
  return create(...args)
}